package chapter67;

import java.util.Scanner;

/*
 * 求5位学员的决赛的平均成绩和最高成绩
 */
public class CalScore {
	public void calScore(Students[] stus) {
		int sum = 0;
		for (int i = 0; i < stus.length; i++) {
			sum += stus[i].score;
		}
		double avgScore = sum / stus.length;
		System.out.println("五位学员的平均成绩为：" + avgScore);
		int maxScore = stus[0].score;
		for (int i = 1; i < stus.length; i++) {
			if (stus[i].score > maxScore) {
				maxScore = stus[i].score;
			}
		}
		System.out.println("五位学员的最高分为：" + maxScore);
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		CalScore cals = new CalScore();
		Students[] stus = new Students[5];
		
		for(Students stu :stus){
			System.out.println(stu);
		}
		System.out.println("请输入五名参赛者的成绩：");
		for (int i = 0; i < stus.length; i++) {
			
			/*stus[i] = new Students();
			stus[i].score = input.nextInt();*/
			
			Students stu = new Students();
			stu.score = input.nextInt();
			stus[i] = stu;
		}
		cals.calScore(stus);
	}

}
